package com.miniportal.base.controller;


import cn.hutool.http.HttpStatus;
import com.miniportal.base.convert.CommercialInfoConvert;
import com.miniportal.base.pojo.CommonResponse;
import com.miniportal.base.pojo.dto.CommercialInfoDto;
import com.miniportal.base.service.ICommercialInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 工商信息 前端控制器
 * </p>
 *
 * @author zhouje
 * @since 2022-05-30
 */
@Controller
@RequestMapping("/commercialInfo")
public class CommercialInfoController {

    @Autowired
    private ICommercialInfoService iCommercialInfoService;

    @GetMapping("/getAll")
    public CommonResponse getAll() {
        return CommonResponse.builder().code(HttpStatus.HTTP_OK)
                .msg("请求成功")
                .data(iCommercialInfoService.selectAll()).build();
    }

    @PostMapping("addOne")
    public CommonResponse addOne(@Validated CommercialInfoDto request) {
        return CommonResponse.builder().code(HttpStatus.HTTP_OK)
                .msg("操作成功")
                .data(iCommercialInfoService.save(CommercialInfoConvert.INSTANCE.dtoToDo(request))).build();
    }

}
